package squarePackage;


import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import Enumerations.Directions;
import Obstacle.Door;
import Obstacle.Wall;

public class TransparantSquareTest {

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		square = new TransparantSquare();
	}

	@After
	public void tearDown() throws Exception {
	}
	
	Square square;
	
	@Test
	public final void constructorStandard(){
		Square testSquare = new TransparantSquare();
		assertEquals(1, testSquare.hasNumberOfDoors());
		assertEquals(1, testSquare.hasNumberBorders());
		assertTrue(testSquare.hasBorder(Directions.North));
	}
	
	@Test
	public final void constructorStandardSouth(){
		Square testSquare = new TransparantSquare(Directions.South);
		assertEquals(1, testSquare.hasNumberOfDoors());
		assertEquals(1, testSquare.hasNumberBorders());
		assertTrue(testSquare.hasBorder(Directions.South));
	}
	
	@Test (expected = IllegalArgumentException.class)
	public final void constructorStandardIllegalFloor(){
		Square testSquare = new TransparantSquare(Directions.Floor);
		}
	
	@Test
	public final void constructorLegalCase(){
		Square testSquare = new TransparantSquare(2,Directions.East);
		assertEquals(2, testSquare.hasNumberOfDoors());
		assertEquals(2, testSquare.hasNumberBorders());
		assertTrue(testSquare.hasBorder(Directions.East));
		assertTrue(testSquare.hasBorder(Directions.West));
	}
	
	@Test
	public final void isValidBorderNoDoorSameDirection(){
		assertTrue(square.isValidBorder(Directions.North, new Wall()));
	}
	
	@Test
	public final void isValidBorderNoDoorOppositeDirection(){
		assertTrue(square.isValidBorder(Directions.South, new Wall()));
	}
	
	@Test
	public final void isValidBorderDoorSameDirection(){
		assertTrue(square.isValidBorder(Directions.North, new Wall(new Door())));
	}
	
	@Test
	public final void isValidBorderDoorOppositeDirection(){
		assertTrue(square.isValidBorder(Directions.South, new Wall(new Door())));
	}
	
	@Test
	public final void isValidBorderIllegal(){
		assertFalse(square.isValidBorder(Directions.East, new Wall()));
	}
	
	@Test
	public final void isValidFloor(){
		Square testSquare = new TransparantSquare(1, Directions.Ceiling);
		assertFalse(testSquare.isValidBorder(Directions.Floor, new Wall()));
	}
	
	@Test (expected = IllegalArgumentException.class)
	public final void constructorIllegalCaseNumberOfWalls(){
		Square testSquare = new TransparantSquare(3, Directions.East);
	}
	
	@Test (expected = IllegalArgumentException.class)
	public final void constructorIllegalCase2WallsCeiling(){
		Square testSquare = new TransparantSquare(2, Directions.Ceiling);
	}
}
